package com.mall.service.commodity.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.model.domain.PmsProduct;
import com.mall.model.domain.PmsSkuStock;
import com.mall.service.commodity.mapper.PmsProductMapper;
import com.mall.service.commodity.mapper.PmsSkuStockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName SkuService
 * @Description sku库存
 * @Author dcq
 * @Date 2023/3/13 19:32
 * @Version 1.0
 */
@Service
public class SkuService {
    @Autowired
    private PmsSkuStockMapper pmsSkuStockMapper;


    public void updateSei(Integer pid, List<PmsSkuStock> skuStockList) {
        for (PmsSkuStock pmsSkuStock : skuStockList) {
            Long id = pmsSkuStock.getId();
            pmsSkuStockMapper.updateById(pmsSkuStock);
        }
    }
    //回显
    public List<PmsSkuStock> getId(Integer pid, String keyword) {
        LambdaQueryWrapper<PmsSkuStock>queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(pid!=null,PmsSkuStock::getProductId,pid);
        queryWrapper.like(keyword!=null,PmsSkuStock::getSkuCode,keyword);
        List<PmsSkuStock> pmsSkuStocks = pmsSkuStockMapper.selectList(queryWrapper);

        return pmsSkuStocks;

    }
}